// Copyright 2011 Dave Ruest.  All rights reserved.

/**
 * @fileoverview Honeybee is a casual nonviolent educational family game.
 */
function Honeybee(game, tiles, size, rows, columns) {
	this.game = game;
	this.size = size;
	var image = game.getImage(tiles);
	this.images = new ImageGrid(game.graphics, image, size, rows, columns);
	
	this.x = size;
	this.y = game.height / 2 - size / 2;
	this.r = 0;
};

Honeybee.prototype.draw = function() {
	var c = 1;
	if (this.game.dy > 0) {
		c = 0;
	} else if (this.game.dy < 0) {
		c = 2;
	}
	
	this.images.draw(this.x, this.y, this.r, c);
};

Honeybee.prototype.onInterval = function() {
	this.y += this.game.dy;
	
	if (this.y < 0) {
		this.y = 0;
	}
	
	if (this.y + this.size > this.game.height) {
		this.y = this.game.height - this.size;
	}
	
	this.r++;
	if (this.r >= this.images.rows) {
		this.r = 0;
	}
};